package edu.lsnu.equipment_management_system.controller;

import edu.lsnu.equipment_management_system.pojo.domain.JsonData;
import edu.lsnu.equipment_management_system.pojo.domain.PageBean;
import edu.lsnu.equipment_management_system.pojo.vo.out.admin.AdminLogVo;
import edu.lsnu.equipment_management_system.service.AdminReviewLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mzy
 * @Description 管理员审核之后的日志
 * @date 2018/11/25
 */
@RestController
public class AdminReviewLogController {
    @Autowired
    AdminReviewLogService adminReviewLogService;

    /**
     * @Description 管理员购入审核日志
     * @author mzy
     * @time 2018-11-25
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/purchaseReviewLog/{pageNum}")
    public Object purchaseReviewLog(@PathVariable Integer pageNum) {
        PageBean<AdminLogVo> adminLogVoPageBean =
                adminReviewLogService.purchaseReviewLog(pageNum);

        if (null == adminLogVoPageBean) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminLogVoPageBean, "操作成功");
        }

    }

    /**
     * @Description 管理员报损报废审核日志
     * @author mzy
     * @time 2018-11-25
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/damageReviewLog/{pageNum}")
    public Object damageReviewLog(@PathVariable Integer pageNum) {
        PageBean<AdminLogVo> adminLogVoPageBean =
                adminReviewLogService.damageReviewLog(pageNum);

        if (null == adminLogVoPageBean) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminLogVoPageBean, "操作成功");
        }
    }

    /**
     * @Description 管理员维修维护审核日志
     * @author mzy
     * @time 2018-11-25
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/repairReviewLog/{pageNum}")
    public Object repairReviewLog(@PathVariable Integer pageNum) {
        PageBean<AdminLogVo> adminLogVoPageBean =
                adminReviewLogService.repairReviewLog(pageNum);

        if (null == adminLogVoPageBean) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminLogVoPageBean, "操作成功");
        }
    }

    /**
     * @Description 管理员调入审核日志
     * @author mzy
     * @time 2018-11-25
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/transferInReviewLog/{pageNum}")
    public Object transferInReviewLog(@PathVariable Integer pageNum) {
        PageBean<AdminLogVo> adminLogVoPageBean =
                adminReviewLogService.transferInReviewLog(pageNum);

        if (null == adminLogVoPageBean) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminLogVoPageBean, "操作成功");
        }
    }

    /**
     * @Description 管理员调出审核日志
     * @author mzy
     * @time 2018-11-25
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/transferOutReviewLog/{pageNum}")
    public Object transferOutReviewLog(@PathVariable Integer pageNum) {
        PageBean<AdminLogVo> adminLogVoPageBean =
                adminReviewLogService.transferOutReviewLog(pageNum);

        if (null == adminLogVoPageBean) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminLogVoPageBean, "操作成功");
        }
    }

    /**
     * @Description 管理员运行使用审核日志
     * @author mzy
     * @time 2018-11-25
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/useRecordReviewLog/{pageNum}")
    public Object useRecordReviewLog(@PathVariable Integer pageNum) {
        PageBean<AdminLogVo> adminLogVoPageBean =
                adminReviewLogService.useRecordReviewLog(pageNum);

        if (null == adminLogVoPageBean) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminLogVoPageBean, "操作成功");
        }
    }
}
